package com.lqg.bookLibrary.adminController;


import com.alibaba.fastjson2.JSONObject;
import com.lqg.bookLibrary.common.core.domain.JsonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/manage/url")
@RestController
@PreAuthorize("hasAnyRole('a')")
public class UrlController {

    String updateUrl = "/user/update";
    String insertUrl = "/user/insert";
    String deleteUrl = "/user/delete";
    String readUrl = "/user/read";
    String topUrl = "/top/user";

    @GetMapping("/{cate}")
    public JsonResult byCate(@PathVariable String cate){

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("updateUrl", "/" + cate + "/update");
        jsonObject.put("insertUrl", "/" + cate + "/insert");
        jsonObject.put("deleteUrl", "/" + cate + "/delete");
        jsonObject.put("readUrl", "/" + cate + "/read");
        jsonObject.put("topUrl", "/top/" + cate);
        jsonObject.put("searchUrl", "/" + cate + "/search");
        return JsonResult.success(jsonObject);

    }

}
